import 'package:flutter/material.dart';

class AnimationWidget extends StatefulWidget {
  const AnimationWidget({Key key}) : super(key: key);

  @override
  _AnimationWidgetState createState() => _AnimationWidgetState();
}

class _AnimationWidgetState extends State<AnimationWidget>
    with SingleTickerProviderStateMixin {
  AnimationController _controller;
  Animation<double> _scaleAnimation;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(
      vsync: this,
      duration: const Duration(milliseconds: 200),
    );
    _scaleAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(_controller);
    _controller.forward();
  }

  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return AnimatedBuilder(
      animation: _scaleAnimation,
      builder: (_, child) {
        return Transform.scale(
          alignment: Alignment.center,
          child: child,
          scale: _scaleAnimation.value,
        );
      },
      child: createPanel(),
    );
  }

  Widget createPanel() {
    return Column(
      // crossAxisAlignment: CrossAxisAlignment.end,
      children: [
        Padding(
          padding: const EdgeInsets.only(right: 12.0),
          child: Image.asset('images/up_arrow.png', width: 8.0, height: 4.0),
        ),
        Container(
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular((10.0)), // 圆角度
          ),
          height: 80.0,
          width: 160.0,
          child: Padding(
            child: Container(
              child: Text('This is a example'),
            ),
            padding: EdgeInsets.all(8),
          ),
        ),
      ],
    );
  }
}
